package com.dtwave.wechat.service.api.dto.req;

import lombok.Data;

/**
 * @author: liuwenxiang.<br>
 * 创建时间 : 2018-12-17 下午7:01.<br>
 * 功能描述 : 分页查询条件.<br>
 */
@Data
public class ReqPageQueryDto extends ReqBaseDto {

    /** 分页7条数据. **/
    public static final int PAGESIZE_OF_10 = 10;

    public static final int PAGESIZE_OF_1024 = 1024;

    /** 升序. **/
    public static final String ASC = "asc";

    /** 降序. **/
    public static final String DESC = "desc";

    /** 创建时间. **/
    public static final String DB_CTIME = "ctime";

    /** 更新时间. **/
    public static final String DB_MTIME = "mtime";

    /** 起始记录数. */
    private int rowStart = 0;

    /** 当前页. */
    private int currentPage = 1;

    /** 每页记录数， 为-1时代表查询所有. */
    private int pageSize = 10;


    private long totalCount;

    private int totalPage;

    /** 排序字段. */
    private String sort;

    /** 排序方式：(升序:asc,降序：desc)默认降序. */
    private String order = DESC;


    public int getRowStart(){
        currentPage = currentPage<0?1:currentPage;
        rowStart = (currentPage-1)*pageSize;
        return rowStart;
    }

    public int getTotalPage(){
        totalPage = (int) Math.ceil(totalCount/Double.parseDouble(String.valueOf(pageSize)));
        return totalPage;
    }


}
